﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using ALPackage;
using System.Linq;
using JetBrains.Annotations;

namespace HYOK
{
    // 游戏管理类
    public class GameComponent 
    {
        //当前游戏状态
        private EGameStatus _m_gameStatus;

        //匹配到的玩家数据
        private List<GamePlayerItem> _m_playerItemList;

        //构造函数
        public GameComponent()
        {
        }

        //开始匹配
        public void startMatch()
        {
            if (_m_gameStatus != EGameStatus.UNSTART)
            {
                ALLog.Error("已经开始匹配");
                return;
            }
            _m_gameStatus = EGameStatus.MATCHING;
            //开始匹配
            Player.instance.gameCompoent.reqStartMatch();
        }

        #region S2C

        /// <summary>
        /// 匹配到玩家
        /// </summary>
        public void retMatched(List<GamePlayerItem> _list)
        {
            if (null == _list || _list.Count != 3)
            {
                ALLog.Error("匹配到的玩家异常 数据为空 或者数量 不为 3");
                return;
            }

            _m_gameStatus = EGameStatus.MATCHED;
            _m_playerItemList = _list;
            WinMsg.SendMsg(WinMsgType.PLAYER_GET_MATCHED);
        }

        #endregion

        #region C2S

        /// <summary>
        /// 游戏开始匹配
        /// </summary>
        public void reqStartMatch(Action _doneAction = null)
        {
            
        }

        #endregion


    }
}
